<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="../common/jspcommon.jsp"%>
<%@include file="../common/jscss.jsp"%>
<script type="text/javascript">
	var artEamilGrid = null;
	var sendEamilGrid = null;
	$(function(){
		artEamilGrid = $("#art_email_grid").ligerGrid({
				title : '订阅邮箱列表',
                columns: [
							{
								display: '<a href="javascript:;" onclick="sendEmail()">发送邮件</a>', 
								name: 'id',
								width:400,
								isAllowHide: false, 
								isSort : false,
								render: function (record, rowindex, value, column){
									var html = '<a onclick="displayEamil(\''+ value + '\')" href="javascript:;">发送</a>&nbsp;<a onclick="hideEamil(\''+ value + '\')" href="javascript:;">不发送</a>&nbsp;'; 
									return html; 
								}
							},
                     	 { display: '当前状态', name: 'enabled',isSort : false,
       	                  render: function(record, rowindex, value, column){
       	                	  if(value){
       	                		  return "<span>发送</span>"; 
       	                	  }else{
       	                		  return "<span>不发送</span>"; 
       	                	  }
       	                	 
       	                  }},
	            { display: 'email', name: 'email',isSort : false },
               
                { display: '创建时间', name: 'gmtCreated',isSort : false,
                  render: function(record, rowindex, value, column){
                	 return (new Date(value.time)).format("yyyy年MM月dd日 hh:mm:ss");
                  }}
                
                ], 
                pageSize:30,
                root :'list',
                record:'totalRecord',
                url: "/misc/reminder/artEmailGrid.htm?type=${type}", 
                width: '99%',height:'99%'
            });


	});
	
	//开启 艺术家
	function displayEamil(id){
		$.post("/misc/artMade/updateEamil.htm", {
			id:id,
			enabled:true
		},function(data){
			if(data=="success"){
				artEamilGrid.loadData();
				$.ligerDialog.success("开启发送！");
			}
			if(data=="error"){
				$.ligerDialog.warn("系统有点抽经，请稍候重试！");
			}
		});
		
	}
	//关闭
	function hideEamil(id){
		$.post("/misc/artMade/updateEamil.htm", {
			id:id,
			enabled:false
		},function(data){
			if(data=="success"){
				artEamilGrid.loadData();
				$.ligerDialog.success("不发送！");
			}
			if(data=="error"){
				$.ligerDialog.warn("系统有点抽经，请稍候重试！");
			}
		});
		
	}
	
	function sendEmail(){
		sendEamilGrid = $.ligerDialog.open({ height: 500,width:800, url: "/misc/reminder/reminder.htm?type=${type}", isResize: false ,modal:true,title:'发送邮件'});
	
	}
</script>
<div id="art_email_grid" style="margin:0; padding:0 ;" ></div>
